#!/bin/sh /etc/rc.common

USE_PROCD=1

START=99

MODBUSBRIDGE_BIN=/usr/bin/modbusbridge
MODBUSBRIDGE_CONFIG='modbusbridge'


start_service() {
    local device
    local baud_rate
    local parity
    local data_bits
    local stop_bits

    local ip_address
    local port


    config_load $MODBUSBRIDGE_CONFIG
 
    config_get device 'rtu' 'device'
    config_get baud_rate 'rtu' 'baud_rate'
    config_get parity 'rtu' 'parity'
    config_get data_bits 'rtu' 'data_bits'
    config_get stop_bits 'rtu' 'stop_bits'

    config_get ip_address 'tcp' 'ipaddr'
    config_get port 'tcp' 'port'


    procd_open_instance

    procd_set_param command "$MODBUSBRIDGE_BIN"
    procd_append_param command "$device" "$baud_rate" "$parity" "$data_bits" "$stop_bits" "$ip_address" "$port"

    procd_close_instance
}
